// 资源导入相关类型定义
// REF: API-SHARE189-004@v1.0

export interface ShareCode {
  id: number;
  shareCode: string;
  accessCode?: string;
  description?: string;
  status: number; // 0-待解析，1-解析中，2-解析完成，3-解析失败，4-已导入
  statusText: string;
  importStatus: number;
  importStatusText: string;
  createdAt: string;
  updatedAt: string;
  shareInfo?: {
    title: string;
    fileCount: number;
    totalSize: number;
    expireTime?: string;
  };
  fileTree?: FileTreeNode[];
}

export interface FileTreeNode {
  id: number;
  name: string;
  size: number;
  isFolder: boolean;
  type?: 'file' | 'folder';
  createTime?: string | null;
  createDate: string;
  lastOpTime: string;
  fileCata: number;
  mediaType?: number | null;
  orientation?: number | null;
  rev: string;
  starLabel: number;
  path: string;
  depth: number;
  downloadUrl?: string | null;
  icon?: {
    largeUrl: string;
    smallUrl: string;
  } | null;
  md5?: string | null;
  children: FileTreeNode[];
}

export interface PreviewResult {
  shareInfo: {
    shareId: number;
    fileId: string;
    shareMode: number;
    shareName: string;
    shareCode: string;
    creator: {
      nickName: string;
      iconURL?: string;
      oper?: boolean;
      ownerAccount?: string;
      superVip?: number;
      vip?: number;
    };
    fileSize: number;
    isFolder: boolean;
  };
  fileInfo: FileTreeNode[];
  statistics: {
    totalFiles: number;
    totalFolders: number;
    totalSize: number;
    fileTypes: Record<string, number>;
    maxDepthReached: number;
  };
}

export interface PaginationInfo {
  page: number;
  perPage: number;
  total: number;
  pages: number;
  hasNext: boolean;
  hasPrev: boolean;
}

export interface ShareCodePreviewProps {
  onPreview: (shareCode: string, accessCode?: string) => Promise<void>;
  previewResult: PreviewResult | null;
  loading: boolean;
}

export interface BatchImportProps {
  onImport: (text: string) => Promise<void>;
}

export interface ShareCodeListProps {
  shareList: ShareCode[];
  loading: boolean;
  pagination: PaginationInfo;
  searchQuery: string;
  statusFilter: string;
  onSearchChange: (query: string) => void;
  onStatusFilterChange: (status: string) => void;
  onSearch: () => void;
  onPageChange: (page: number) => void;
  onViewDetail: (shareId: number) => void;
  onParse: (shareId: number) => void;
  onDelete: (shareId: number) => void;
  onImportToVirtualDisk: (shareId: number) => void;
  onRefresh: () => void;
}

export interface FileTreeProps {
  nodes: FileTreeNode[];
  level?: number;
}

export interface ShareDetailDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  shareData: ShareCode | null;
}